import { http } from '@/utils/request'
import type { BaseSaleAttrValueName, ISpuData, ISpuListItem, spuImage } from '@/api/types'

/**
 * @description spu列表
 * @param page
 * @param limit
 * @param category3Id
 */
export const reqSpuList = (page: number, limit: number, category3Id: string) => {
  return http<ISpuData>(`/admin/product/${page}/${limit}?category3Id=${category3Id}`, 'GET')
}

/**
 * @description spu详情
 * @param spuId
 */
export const reqSpuDetail = (spuId: number) => {
  return http<ISpuListItem>(`/admin/product/getSpuById/${spuId}`, 'GET')
}

/**
 * @description 删除spu
 * @param spuId
 */
export const reqDelSpuItem = (spuId: string) => {
  return http(`/admin/product/deleteSpu/${spuId}`, 'DELETE')
}

/**
 * @description 获取指定id的spu图片列表
 * @param spuId
 */
export const reqSpuImageList = (spuId: number) => {
  return http<spuImage[]>(`/admin/product/spuImageList/${spuId}`, 'GET')
}

export const reqAllSaleAttrValue = () => {
  return http<BaseSaleAttrValueName[]>('/admin/product/baseSaleAttrList', 'GET')
}

export const reqAddSpu = (data: ISpuListItem) => {
  return http('/admin/product/saveSpuInfo', 'POST', data)
}

export const reqEditSpu = (data: ISpuListItem) => {
  return http('/admin/product/updateSpuInfo', 'POST', data)
}
